import request from "@/utils/Request";

export default class UserApiRequest {
  // 获取验证码
  async getCaptchaImg(data) {
    return Promise.resolve(request.getCaptchaImg("/api/user/captcha", data));
  }
  // 获取邮箱验证码
  async getEmailCaptcha(data) {
    return Promise.resolve(request.get("/api/user/emailCaptcha", data));
  }

  // 用户登录
  async loginUser(data) {
    return Promise.resolve(request.postFormByLogin("/api/login", data));
  }

  // 用户登出
  async logOutUser() {
    return Promise.resolve(request.get("/api/logout"));
  }

  async registryUser(data) {
    return Promise.resolve(
      request.postFormByRegistry("/api/user/registry", data)
    );
  }

  async updateUserInfo(data) {
    return Promise.resolve(request.postForm("/api/user/update/userInfo", data));
  }

  // 单个文章的内容获取
  async getUserArticleContent(data) {
    return Promise.resolve(request.get("/api/user/userArticleContent", data));
  }

  //根据用户id获取文章
  async getArticleByUserId(data) {
    return Promise.resolve(request.postForm("/api/user/userArticle", data));
  }

  // 删除用户文章
  async delUserArticle(data) {
    return Promise.resolve(request.delArticle("/api/article/delete", data));
  }

  //获取用户博客账号信息
  async getUserBlogInfo(data) {
    return Promise.resolve(request.get("/api/user/blogInfo", data));
  }

  // 关注
  async followUser(data) {
    return Promise.resolve(request.postForm("/api/follow/followUser", data));
  }
  //取消关注
  async unFollowUser(data) {
    return Promise.resolve(request.postForm("/api/follow/unFollowUser", data));
  }

  // 获取用户的好友
  async getUserFriend(data) {
    return Promise.resolve(request.get("/api/friend/list", data));
  }

  // 获取与当前好友的聊天记录
  async getChattingRecords(data) {
    return Promise.resolve(request.postForm("/api/chatting/record_list", data));
  }

  // 获取所有用户信息
  async getUserInfo(data) {
    return Promise.resolve(request.postForm("/api/friend/user_list", data));
  }

  // 添加好友
  async addFriend(data) {
    return Promise.resolve(request.postForm("/api/friend/add_friend", data));
  }
}
